﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class UserWork_GroupPub : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"] == null)
        {
            Response.Write("<script>alert('请先登录!');window.location.href='../Login.aspx'</script>");
        }
    }
    protected void bnSave_ServerClick(object sender, EventArgs e)
    {
        if (this.txName.Value.Trim() == "")
        {
            Response.Write("<script>alert('请输入分组名称')</script>");
        }
        else
        {

            SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Connection"]);
            con.Open();
            string UserName = Session["UserName"].ToString();
            string sql = "insert grouping values('" + txName.Value.Trim() + "','" + UserName + "')";
            SqlCommand com = new SqlCommand(sql, con);
            com.ExecuteNonQuery();

            con.Close();
            Response.Write("<script>alert('添加成功！！');window.location.href='MyGrouping.aspx';</script>");
           
        }
    }
}
